home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: redoConvertToLargeHdr.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:58 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "log.h"
- #include "pool.h"
- #include "volume.h"
- #include "logrecs.h"
- #include "trans.h"
- #include "openlog.h"
- #include "bitmap.h"
- #include "bf_extfuncs.h"
- #include "bm_extfuncs.h"
- #include "trans_extfuncs.h"
- #include "redo_intfuncs.h"
- #include "redo_extfuncs.h"
- #include "sm_extfuncs.h"
- #include "logaction.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "log_globals.h"
- #include "log_extfuncs.h"
- #include "sm_macro.h"
- #include "bf_macro.h"
-
-
- void
- redoConvertToLargeHdr (
-
- LOGRECORDHDR *record
- )
- {
- PID *pid;
- GROUPLINK *groupLink;
- SLOTTEDPAGE *slottedPage;
- SMALLOBJ *logObj;
- SMALLOBJ *origObj;
- OID *oid;
- PAGESLOT *slotPtr;
-
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
-
- /*
- * get a pointer to the page for the record
- */
- pid = &(record->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /*
- * get pointer to oid, and the new object data
- */
- oid = (OID*) GET_LOG_IMAGE(record, 0);
- logObj = (SMALLOBJ*) GET_LOG_IMAGE(record, 1);
- SM_ASSERT(LEVEL_3, GET_LOG_IMAGE_SIZE(record, 1) == sizeof(LARGEOBJHDR));
-
- /*
- * See if the operation needs to be redone
- */
- if (!redoCheckPage(record, &groupLink, PAGE_SLOTTED)) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
- return;
- }
- CHECK_GROUPLINK_MAGIC(groupLink);
-
- /*
- * get a pointer to the slotted page
- */
- slottedPage = (SLOTTEDPAGE *) groupLink->bufFrame;
- if (CHECK_SLOTTED_MAGIC(slottedPage)) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * Get a pointer to the slot and then the object
- */
- SM_ASSERT(LEVEL_3, oid->diskAddr.slot < slottedPage->header.slotCount);
- slotPtr = GETSLOTPTR(slottedPage, oid->diskAddr.slot);
- SM_ASSERT(LEVEL_3, oid->diskAddr.unique == slotPtr->unique);
- origObj = GETOBJECTPTR(slottedPage, slotPtr);
-
- /*
- * The object should have enough room to hold the pid of the
- * large object root page.
- */
- SM_ASSERT(LEVEL_3, ALIGNSIZE(origObj->objectHdr.size) == ALIGNSIZE(sizeof(SHORTPID)) || (origObj->objectHdr.properties & (P_MOVED|P_HEADERONPAGE)));
-
-
- /*
- * If the original object was forwarded or a large root then
- * space is freed up on the page.
- */
- if (origObj->objectHdr.properties & P_MOVED) {
-
- SM_ASSERT(LEVEL_3, (record->type == LOG_REC_TYPE_COMPENSATION) ||
- (GET_LOG_IMAGE_SIZE(record, 2) == sizeof(OBJHDR) + sizeof(OID)));
-
- /* now only a pid is stored instead of an oid */
- slottedPage->header.freeBytes += ALIGNSIZE(sizeof(OID)) - ALIGNSIZE(sizeof(SHORTPID));
- } else if (origObj->objectHdr.properties & P_HEADERONPAGE) {
-
- SM_ASSERT(LEVEL_3, (record->type == LOG_REC_TYPE_COMPENSATION) ||
- (GET_LOG_IMAGE_SIZE(record, 2) == sizeof(OBJHDR) + sizeof(LGSLOTROOT)));
-
- /* now only a pid is stored instead of a large root */
- slottedPage->header.freeBytes += sizeof(LGSLOTROOT) - ALIGNSIZE(sizeof(SHORTPID));
- } else {
- SM_ASSERT(LEVEL_3, (record->type == LOG_REC_TYPE_COMPENSATION) ||
- (GET_LOG_IMAGE_SIZE(record, 2) == sizeof(LARGEOBJHDR)));
- }
-
- /*
- * Redo the conversion by writing the root pid and
- * updating the object header
- */
- if (origObj->objectHdr.properties & P_LARGEOBJ) {
- SM_ASSERT(LEVEL_3, origObj->objectHdr.properties & P_HEADERONPAGE);
- } else {
- slottedPage->header.largeCount++;
- }
- *((SHORTPID*)origObj->data) = *((SHORTPID*)logObj->data);
- origObj->objectHdr = logObj->objectHdr;
-
- /*
- * mark the lrc on the page
- */
- slottedPage->header.lrc = record->actionLRC;
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d, ", slottedPage->header.lrc.count));
-
- /*
- * validate the page
- */
- sm_AuditSlotPage(slottedPage);
-
- /*
- * signal the semaphore
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
-
- /*
- * unfix the page
- */
- bf_UnfixPage(groupLink, BF_DEFAULT, TRUE);
- }
-